﻿using System;
using System.IO;
using System.Runtime.InteropServices;

namespace oueb.react.help
{
    internal class helper
    {
        public static bool IsOutOfScope(string targetPath, string baseDir)
        {
            string fullBase = Path.GetFullPath(baseDir);
            string fullTarget = Path.GetFullPath(targetPath);
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                fullBase = fullBase.ToLowerInvariant();
                fullTarget = fullTarget.ToLowerInvariant();
            }
            bool isBelongToBase = fullTarget == fullBase
                                 || fullTarget.StartsWith(fullBase + Path.DirectorySeparatorChar);
            return !isBelongToBase;
        }
    }
}
